//
//  ZXFmMyListenView.m
//  XIMaLaYaFM
//
//  Created by fanzhuxian on 2017/9/1.
//  Copyright © 2017年 FanZhuxian. All rights reserved.
//

#import "ZXFmMyListenView.h"
#import "UIButton+JFAdd.h"


@interface ZXFmMyListenView ()

@property (nonatomic, strong) UIView * headView;

@end

@implementation ZXFmMyListenView

- (instancetype)initWithFrame:(CGRect)frame {

    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
    }
    return self;
}

- (void)setupView {

    _headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, DEVICE_SCREEN_WIDTH, 120)];
    _headView.backgroundColor = [UIColor colorWithRed:246 / 255.0 green:246 / 255.0 blue:246 / 255.0 alpha:1.0];
    [self addSubview:_headView];
    
    NSArray * buttonNames = @[@"下载", @"历史", @"已购", @"喜欢"];
    NSArray * buttonImages = @[@"top_download_n", @"top_history_n", @"mylogin_shopping", @"myListien_button_like"];
    // 创建按钮
    [self initHeadButtonsWithButtonNames:buttonNames andButtonImages:buttonImages];
    
    
}

- (void)initHeadButtonsWithButtonNames:(NSArray *)buttonNames andButtonImages:(NSArray *)buttonImages {

    for (int i = 0; i < buttonNames.count; i++) {
        
        UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
        CGFloat buttonW = DEVICE_SCREEN_WIDTH / 4;
        
        button.frame = CGRectMake(i * buttonW, 0, buttonW, 100);
        [button setTitle:buttonNames[i] forState:UIControlStateNormal];
        button.backgroundColor = [UIColor whiteColor];
        [button jf_layoutButtonWithEdgeInsetsStyle:JF_ButtonEdgeInsetsStyleTop imageTitleSpace:13];
        [button setImage:[UIImage imageNamed:buttonImages[i]] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:17];
        [self.headView addSubview:button];
    }
}

@end
